package com.buddy.design.pattern._02singleton;

public class LazySimpleSingleton {

    private static LazySimpleSingleton INSTANCE;

    private LazySimpleSingleton() {

    }

    public static LazySimpleSingleton getInstance() {
        //在被外部调用的时候才会被初始化
        if (INSTANCE == null)
            INSTANCE = new LazySimpleSingleton();
        return INSTANCE;
    }

    //static方法会导致整个类被锁
    public static synchronized LazySimpleSingleton getInstanceV2() {
        //在被外部调用的时候才会被初始化
        if (INSTANCE == null)
            INSTANCE = new LazySimpleSingleton();
        return INSTANCE;
    }


}